#include<bits/stdc++.h>
using namespace std;
void solve2()
{
	string ss;
	cin >> ss;
	int n2 = ss.size();
	string tmp;
	for (int i = 1; i < n2-1; i++)
	{
		tmp.push_back(ss[i - 1]);
		if (ss[i] == 'a')
		{
			cout << tmp<<" " << "a" << " " << ss.substr(i + 1, n2 - i - 1) << endl; return;
		}
	}
	cout << ss[0] << " " << ss.substr(1, n2 - 2) << " " << ss[n2 - 1] << endl;;
}

int main()
{
	int T; cin >> T;
	while (T--) solve2();
	return 0;
}